package org.example.font.controller;


import org.example.font.model.Emp;
import org.example.font.model.LoginInfo;
import org.example.font.model.Result;
import org.example.font.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private EmpService empService;


    @PostMapping
    public Result login(@RequestBody Emp emp) {
        System.out.println(emp);
        LoginInfo logininfo = empService.login(emp);

        if (logininfo != null) {
            return Result.success(logininfo);
        }

        return Result.error("登录失败，账号或用户名错误");
    }

}
